/*
 *  CC3PerformanceWorld.h
 *  cocos3d-x
 *
 *  Created by Yezhiyong on 12-4-24.
 *  Copyright 2012 __MyCompanyName__. All rights reserved.
 *
 */

#ifndef __CC3PERFORMANCEWORLD_H__
#define __CC3PERFORMANCEWORLD_H__

#include "CC3World.h"
#include "CC3NodeVisitor.h"
#include "cocos2d.h"
using namespace cocos2d;

class CC3Node;
class NodeGrid;

class CC3PerformanceWorld : public CC3World 
{
public:
	CC3PerformanceWorld();
	~CC3PerformanceWorld();
	
	static CC3PerformanceWorld* world();
	
	void initializeWorld();
	
	void updateBeforeTransform(CC3NodeUpdatingVisitor* visitor);
	
	void updateCameraFromControls(ccTime dt);
	
	void layoutGrid();
	
	CC3Node* getTemplateNode();
	void setTemplateNode(CC3Node * aNode);
	
	void setPerSideCount(unsigned int aCount);
	
	CC3NodeUpdatingVisitor* updateVisitorClass(ccTime dt);
	
protected:
	CCMutableArray<CC3Node*>* availableTemplateNodes;
	
	NodeGrid* nodeGrid;
	
	CC3Node* templateNode;
	
	unsigned int perSideCount;
	
	bool shouldAnimateNodes;
};

class CC3AnimatingVisitor : public CC3NodeUpdatingVisitor
{
public:
	bool nodeIsFromTemplate(CC3Node* aNode);
	
	void processBeforeChildren(CC3Node* aNode);
	
	static CC3AnimatingVisitor* visitorWithDeltaTime(ccTime dt);
};


#endif //__CC3PERFORMANCEWORLD_H__

